#include <gtk/gtk.h>
//#include "gndmodule.h"

#include "gnd.h"

G_DEFINE_INTERFACE(GndModule, gnd_module, G_TYPE_OBJECT)

#define MODULE_NAME "GndModuleInterface"

void gnd_module_default_start(GndModule * self, gpointer data);
void gnd_module_default_stop(GndModule * self, gpointer data);
void gnd_module_default_connect_status(GndModule * self,
                                       int status,
                                       gpointer data);

void gnd_module_default_init(GndModuleInterface * iface)
{
    iface->start = gnd_module_default_start;
    iface->stop = gnd_module_default_stop;
    iface->connect_status = gnd_module_default_connect_status;
}

void gnd_module_start(GndModule * self, gpointer data)
{
    GndModuleInterface * iface;
    g_return_if_fail(GND_IS_MODULE(self));

    iface = GND_MODULE_GET_IFACE(self);
    g_return_if_fail(iface != NULL);
    iface->start(self, data);
}


void gnd_module_stop(GndModule * self, gpointer data)
{
    GndModuleInterface * iface;
    g_return_if_fail(GND_IS_MODULE(self));

    iface = GND_MODULE_GET_IFACE(self);
    g_return_if_fail(iface != NULL);
    iface->stop(self, data);
}

void gnd_module_connect_status(GndModule *self, int status, gpointer data)
{
    GndModuleInterface * iface;
    g_return_if_fail(GND_IS_MODULE(self));

    iface = GND_MODULE_GET_IFACE(self);
    g_return_if_fail(iface != NULL);
    iface->connect_status(self, status, data);
}



void gnd_module_default_start(GndModule * self, gpointer data)
{
    g_warning(MODULE_NAME": default start");
}

void gnd_module_default_stop(GndModule * self, gpointer data)
{
    g_warning(MODULE_NAME": default stop");
}

void gnd_module_default_connect_status(GndModule * self,
                                       int status,
                                       gpointer data)
{
    g_warning(MODULE_NAME": default connect_status");
}
